package com.tianji.mq.consumer;

import com.tianji.medical.pojo.PatientMedication;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import static com.tianji.common.constant.MqConstants.CONSUMER;
import static com.tianji.common.constant.MqConstants.TOPIC_DLQ;

@Component
@RequiredArgsConstructor
@Slf4j
@RocketMQMessageListener(topic = TOPIC_DLQ,consumerGroup = CONSUMER)
public class DLQConsumer implements RocketMQListener<PatientMedication> {

    private final MedicationRemindConsumer remindConsumer;

    @Override
    public void onMessage(PatientMedication message) {
        try{
            //重新发送提醒信息
            remindConsumer.sendWeChatReminder(message);
            log.info("重新发送消息成功");
        }catch (Exception e){
            log.error("重新发送消息失败{}", e.getMessage());
            // 转人工处理
            //manualProcessingService.saveForManualProcessing(message, e.getMessage());
        }
    }
}
